<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>修改一个分类</title>
</head>
<body>
<script>
    $(function () {
        $("#editProC-form").form({
           onLoadSuccess:function () {
               $("#hut-pcid").next().hide();
               var queryParams = $("#searchBymh2").combobox('options').queryParams;
               queryParams.noteq = $("#hut-pcid").val();
           }
        });

        //提交修改表单
        $("#editProC-save").linkbutton({onClick:function () {
                var row = $("#pcdg").datagrid("getSelected");
                $("#editProC-form").form({
                    onSubmit:function () {
                        return $(this).form("validate");
                    },
                    success:function (data) {
                        var data = eval("("+data+")");
                        if(data.success){
                            $("#editProC"+row.pcid).dialog("close");
                            $.messager.alert("success","修改成功!","info");
                            $("#pcdg").datagrid({
                                url:'allProCategories',
                                method:'post'
                            });
                            $("#pcdg").datagrid("reload");
                        }else{
                            $.messager.alert("failed",data.message,"error");
                        }

                    }
                }).submit();
            }

        });

        $("#editProC-close").linkbutton({onClick:function () {
                var row = $("#pcdg").datagrid("getSelected");
                $("#editProC"+row.pcid).dialog("close");
            }});
        $("#searchBymh2-tip").tooltip({
            position:'bottom',
            content:'<span style="color:red;">请输入父分类id或者父分类名称!，填写0则为一级分类</span>',
            onShow:function(){
                $(this).tooltip('tip').css({
                    backgroundColor:'#666',
                    borderColor:'#666'
                });
            }

        });
        $("#searchBymh2").combobox({
            onBeforeLoad: function(param){
                if(param == null || param.q == null || param.q.replace(/ /g, '') == ''){
                    var value = $(this).combobox('getValue');
                    if(value){// 修改的时候才会出现q为空而value不为空
                        param.id = value;
                        return true;
                    }
                    return false;
                }

            }
        });
    });
</script>
<div class="form-div">
    <form id="editProC-form" action="editProC-form-sub" method="post">
        <div class="div-title-hut"> ----------------------------<span class="span-title">分类信息</span>------------------------------</div>
        <div style="text-align: center; margin:50px;">
            <input  id="hut-pcid" name="pcid" class="easyui-textbox" data-options="border:false">
            <input id="hut-pcname" name="pcname" class="easyui-textbox" data-options="label:'分类名称',required:true,width:300">
        </div>
        <div style="text-align: center;margin:50px;padding-left: 14px;">
            <input id="searchBymh2" name="pcpid" class="easyui-combobox" data-options="required:false,prompt:'若不填写，则保留原有的父分类',url:'getAllCategoryBymh2',label:'父分类',labelWidth:'70',
            valueField:'pcid',
            textField:'pcname',
            method:'post',editable:true,panelHeight:'auto',width:300,mode:'remote'" />
            <a id="searchBymh2-tip" href="javascript:void(0)">tip</a>
        </div>
        <div style="text-align: center;margin:50px">
            <input id="hut-pcpriority" name="pcpriority" class="easyui-textbox" data-options="label:'分类优先级',required:true,width:400,prompt:'输入分类优先级，同级分类中优先级高的将显示在前面'">
        </div>
        <div class="btn ddn">
            <a id="editProC-save" class="easyui-linkbutton " data-options="iconCls:'icon-ok2'">设置</a>
            <a id="editProC-close" class="easyui-linkbutton" data-options="iconCls:'icon-cancel2'">取消</a>
        </div>
    </form>
</div>
</body>
</html>
